﻿using Xc.DataAccess.Core;

namespace Xc.DataAccess.Core.Services
{
    /// <summary>
    /// 转换器服务
    /// </summary>
    public interface IConverterService
    {
        /// <summary>
        /// 将字节码数组转换为对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <returns></returns>
        ResultData<T> FromBinaryArray<T>(byte[] data);

        /// <summary>
        /// 从Json字符串回转回来
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="jsonText"></param>
        /// <returns></returns>
        T FromJsonString<T>(string jsonText);

        /// <summary>
        /// 从XMl字符串回转回来
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="xml"></param>
        /// <returns></returns>
        T FromXmlString<T>(string xml);

        /// <summary>
        /// 将Yaml字符串转换为对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="yamlText"></param>
        /// <returns></returns>
        T FromYamlString<T>(string yamlText);

        /// <summary>
        /// 转换为字节码数组
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <returns></returns>
        ResultData<byte[]> ToBinaryArray<T>(T data);

        /// <summary>
        /// 转换为Json字符串
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <returns></returns>
        string ToJsonString<T>(T data);

        /// <summary>
        /// 转换为xml 字符串
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <returns></returns>
        string ToXmlString<T>(T data);

        /// <summary>
        /// 将对象转换为Yaml字符串
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <returns></returns>
        string ToYamlString<T>(T data);
    }
}
